package com.foreknow.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller

public class HelloController {

    @RequestMapping(path = "/hello",method = RequestMethod.GET)
    public String printHello(ModelMap modelMap) {
        //ModelMap对象可以用于在服务器端保存数据addAttribute(k,v)
//        request.setAttribute("message","adsfasdf")
        modelMap.addAttribute("info","test springmvc");
        //返回的字符串hello会根据SpringMVC的视图解析器找到WEB-INFO-->jsp--->hello.jsp
        return "hello";
    }
}
